<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>wxpay</title>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src='http://res.wx.qq.com/open/js/jweixin-1.0.0.js'></script>
</head>
<body>

<p>微信支付</p>
<script >
    $(document).ready(function(){
        $("p").click(function(){

            $.ajax({
                type : "get",
                url : "api/Sign/wxpay",
                async: false,
                // dataType:"json",

                success : function(data) {

                    console.log(data);
                    // if (json.result == "ok") {
                    //     window.location.href = json.mwebUrl;
                    // } else {
                    //     alert(json.desc);
                    // }


                        //调用微信JS api 支付
                        function jsApiCall()
                        {
                            WeixinJSBridge.invoke(
                                'getBrandWCPayRequest',
                                function(res){

                                    alert(res.err_code+res.err_desc+res.err_msg);
                                }
                            );
                        }

                    function callpay()
                    {
                        if (typeof WeixinJSBridge == "undefined"){
                            if( document.addEventListener ){
                                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                            }else if (document.attachEvent){
                                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                            }
                        }else{
                            jsApiCall();
                        }
                    }



                },error: function(XMLHttpRequest, textStatus, errorThrown) {
                    console.log(XMLHttpRequest.status);
                    console.log(XMLHttpRequest.readyState);
                    console.log(textStatus);
                }
            });

        });
    });

</script>
</body>
</html>
